package com.ct.controller;

import cn.hutool.core.lang.Console;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.thread.ThreadUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ct.model.entity.CityInfo;
import com.ct.model.entity.SysUser;
import com.ct.server.ICityInfoService;
import com.ct.server.ISysUserServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;


/**
 * 多数据库链接测试
 */
@RestController
@RequestMapping("/dynamic")
public class DynamicController {

    @Autowired
    public ICityInfoService iCityInfoService;

    @Autowired
    public ISysUserServer iSysUserServer;


    @GetMapping("test")
    public Map dnmae() {
        Page<CityInfo> cityInfoPage = new Page<>(2, 10);
        Page cityInfoList = iCityInfoService.page(cityInfoPage);
        Console.log("cityInfoList.getRecords:{}", cityInfoList.getRecords());
        Page<SysUser> sysUserPage = new Page<>(2, 10);
        Page sysUserList = iSysUserServer.page(sysUserPage);
        Console.log("sysUserList.getRecords:{}", sysUserList.getRecords());

        return  MapUtil.builder(new HashMap<String, Object>())
                .put("cityInfoList", cityInfoList)
                .put("sysUserList", sysUserList).build();
    }
}
